from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

from src.util import *

class HomePage(webapp.RequestHandler):
    def get(self):
        template_values = {
            'page': { 'title': 'Home' , 'name' : 'home' }
        }
        
        appInfo = getApplicationInfo()
        if appInfo.appId:
             template_values['appId'] = appInfo.appId

        self.response.out.write(template.render(get_absolute_path('templates/home.htm'), template_values))

    def post(self):
        appInfo = getApplicationInfo()
        id = self.request.get('appid')
        if id:
            appInfo.appId = id
            appInfo.put() 
        self.redirect('/home')
